컬렉션 및 배열에서 간단한 구문을 제공한다.
반복문에 반복할 길이와 증가치를 정의할 필요가 없다.
for (String str:str_arr){
System.out.println(str);
}
public class Before_Loop{
public static void main(String[] args){
String[] str_arr = {"one","two","three","four"};
for (int i=0; i <str_arr.length; i++){
System.out.println(str_arr[i]);
}
}
}
public class After_Loop{
public static void main(String[] args){
String[] str_arr = {"one","two","three","four"};
for (String str:str_arr){
System.out.println(str);
}
}
}